package com.czd.base.utils;

import java.util.Random;

/**
 * 创建随机码工具类
 * @author junyang
 *
 */
public class GenerateRandCodeUtils {
	private static Random random = new Random();
	private static String randString = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";// 随机产生的字符串

	/**
	 * 创建随机邀请码
	 * @param stringNum 随机产生字符数量
	 * @return
	 */
	public static String createRandInviteCode(int stringNum) {
		StringBuilder sb = new StringBuilder();
		
		for(int i = 0, size = randString.length(); i < stringNum; i++) {
			sb.append(randString.charAt(random.nextInt(size))) ;
		}
		
		return sb.toString();
	}
	
	public static void main(String[] args) {
		for(int i = 0; i < 1000; i++) {
			System.out.println(GenerateRandCodeUtils.createRandInviteCode(6));
		}
	}
}
